﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace Hangout.Client.Controls.Hangouts
{
    public partial class HangoutComments : UserControl
    {
        public HangoutComments()
        {
            InitializeComponent();
        }

        private List<MeetupService.HangoutComment1> hangoutComments;

        public List<MeetupService.HangoutComment1> HangoutComment
        {
            get
            {
                try
                {
                    return hangoutComments;
                }
                catch (Exception ex)
                {
                    Core.Exceptions.ExceptionReporting.Report(ex);
                    
                    MessageBox.Show(ErrorText.GenericErrorText, ErrorText.GenericErrorCaption, MessageBoxButton.OK);
                    return new List<MeetupService.HangoutComment1>();
                }
            }
            set
            {
                try
                {
                    hangoutComments = value;
                    UpdateData();
                }
                catch (Exception ex)
                {
                    Core.Exceptions.ExceptionReporting.Report(ex);
                    MessageBox.Show(ErrorText.GenericErrorText, ErrorText.GenericErrorCaption, MessageBoxButton.OK);
                }

            }
        }

        private void UpdateData()
        {

            try
            {
                if (hangoutComments.Count > 0)
                {
                    HangoutCommentsLB.DataContext = hangoutComments;

                    HangoutCommentsLB.ItemsSource = null;
                    HangoutCommentsLB.ItemsSource = hangoutComments;
                    HangoutCommentsLB.Visibility = System.Windows.Visibility.Visible;
                    NoLBL.Visibility = System.Windows.Visibility.Collapsed;
                }
                else
                {
                    HangoutCommentsLB.Visibility = System.Windows.Visibility.Collapsed;
                    NoLBL.Visibility = System.Windows.Visibility.Visible;
                }
            }
            catch (Exception ex)
            {
                Core.Exceptions.ExceptionReporting.Report(ex);
                MessageBox.Show(ErrorText.GenericErrorText, ErrorText.GenericErrorCaption, MessageBoxButton.OK);
            }

            
        }
    }
}
